package com.solution.service;

import javax.ejb.EJBException;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;

import org.apache.log4j.Logger;
import org.jboss.annotation.ejb.RemoteBinding;

import com.solution.constant.ErrorMessages;
import com.solution.dao.DAOFactory;
import com.solution.dao.ImageTypeDAO;
import com.solution.exception.DAOException;
import com.solution.exception.ServiceBeanException;
import com.solution.model.ImageType;

@Stateless
@Remote(ImageTypeService.class)
@RemoteBinding(jndiBinding="ImageTypeService")
@TransactionManagement(TransactionManagementType.CONTAINER)
public class ImageTypeServiceImpl {

	/**
	 * DAO instance.
	 */
	private ImageTypeDAO imageTypeDao = (ImageTypeDAO)DAOFactory.getDAOInstance(ImageTypeDAO.class.getName());
	
	/**
	 * Logger instance.
	 */
	private Logger log = Logger.getLogger(ImageTypeServiceImpl.class.getName());

	public ImageType fetchImageType(Long imageTypeId) throws ServiceBeanException{
		try{
			log.debug("Entering :: ImageTypeServiceImpl:fetchImageType()");
			return imageTypeDao.read(imageTypeId);
		}
		catch(DAOException ex){
			log.error(ErrorMessages.IMAGE_TYPE_READ_EXCEPTION, ex);
			throw new EJBException(ex);
		}
	}
}
